{% extends 'admin/base_site.html' %}
{% load i18n admin_urls static admin_list %}

{% block extrastyle %}
  {{ block.super }}
  <link rel="stylesheet" type="text/css" href="{% static "admin/css/changelists.css"%}">
{% endblock %}

{% if not is_popup %}
  {% block breadcrumbs %}
    <div class="breadcrumbs">
      <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
      &rsaquo; Management pages
      &rsaquo; Analyze model fetches
    </div>
  {% endblock %}
{% endif %}

{% block content %}
  <div id="content-main">
    <h2>Model fetches</h2>
    <div id="changelist">
      <table class="stats">
        <thead>
          <tr>
            <th rowspan="2">API Class</th>
            <th colspan="4"># Uses</th>
            <th colspan="3">Times (sec)</th>
          </tr>
          <tr>
            <th>Hits</th>
            <th>Hits%</th>
            <th>Misses</th>
            <th>Both</th>
            <th>Hits</th>
            <th>Misses</th>
            <th>Both</th>
          </tr>
        </thead>
        <tbody>
          {% for item, info in records %}
            <tr>
              <td>{{ item|truncatechars:150 }}</td>
              <td>{{ info.uses.hits }}</td>
              <td>{{ info.uses.hits_percentage }}</td>
              <td>{{ info.uses.misses }}</td>
              <td>{{ info.uses.both }}</td>
              <td>{{ info.times.hits }} ms</td>
              <td>{{ info.times.misses }} ms</td>
              <td>{{ info.times.both }} ms</td>
            </tr>
          {% endfor %}
        </tbody>
      </table>
    </div>

    <div>
      <h2>How This Works</h2>
      <p>
        Every time our Django views need data from the implementation classes, a
        bean counter is incremented on it being used, how long it took
        and whether or not it was able to benefit from the cache.
      </p>
    </div>
  </div>
{% endblock %}
